package intefaceBased;

import util.NumberNotFoundException;

/**
 * Created with IntelliJ IDEA.
 * User: Gauss
 * Date: 22.10.13
 * Time: 23:42
 * To change this template use File | Settings | File Templates.
 */
public class FactorialPascalTriangle implements AbstractPascalTriangle {
    @Override
    public int calcTriangle(int column, int row) throws NumberNotFoundException {
        if (column>row || row<0 || column<0) throw new NumberNotFoundException();
        return factorial(row)/(factorial(column)*factorial(row - column));
    }

    public static int factorial(int n) {
        if (n<=1) return 1;
        return n*factorial(n-1);
    }
}
